<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>系统功能</title>
	<link rel="stylesheet" type="text/css" href="${ctx}/themes/gray/easyui.css">
	<link rel="stylesheet" type="text/css" href="${ctx}/themes/icon.css">
	<script type="text/javascript" src="${ctx}/script/jquery.min.js"></script>
	<script type="text/javascript" src="${ctx}/script/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="${ctx}/script/lhgdialog/lhgdialog.min.js?s=facebook"></script>
	<script type="text/javascript" src="${ctx}/script/CheckText.js"></script>
	<script type="text/javascript">
		var dg = frameElement.lhgDG;
		dg.addBtn( 'ok', '保存', function(){
			if (!checkFormItem(document.getElementById("dlh"),"C",50,0,1,"登录号")) return false;
			if (!checkFormItem(document.getElementById("mc"),"C",50,0,1,"姓名")) return false;
			checkUnique();
		});
		
		function checkUnique() {
			var pId = $("#id").val();
			var pDlh = $("#dlh").val();
			var params = {
				"gg_czyb.id" : pId,
				"gg_czyb.dlh" : pDlh,
			};
			var actionUrl = "checkUniqueDlh.action";
			$.ajax( {
				url : actionUrl,
				data : params,
				dataType : "json",
				cache : false,
				error : function(textStatus, errorThrown) {alert("系统ajax交互错误: " + textStatus);},
				success : function(data, textStatus) {
					if (data.ajaxResult == "success") {
						submitForm();
					} else {
						alert("登录号已被占用，请重新录入！");
						return false;
					}
				}
			});
		}
		
		function submitForm() {
			var pId = $("#id").val();
			var pJgbh = $("#jgbh").val();
			var pDlh = $("#dlh").val();
			var pMc= $("#mc").val();
			var params = {
				"gg_czyb.id" : pId,
				"jgbh" : pJgbh,
				"gg_czyb.dlh" : pDlh,
				"gg_czyb.mc" : pMc
			};
			//alert(pJgbh);
			var actionUrl = "saveJgry.action";
			$.ajax( {
				url : actionUrl,
				data : params,
				dataType : "json",
				cache : false,
				error : function(textStatus, errorThrown) {alert("系统ajax交互错误: " + textStatus);},
				success : function(data, textStatus) {
					if (data.ajaxResult == "success") {
						var dataRow = {
							ID: data.gg_czyb.id,
							DLH: data.gg_czyb.dlh,
							MC: data.gg_czyb.mc
						};
						if(pId == "") {
							dg.curWin.$("#gridTable").addRowData(data.gg_czyb.id, dataRow, "last");
							new dg.curWin.$.dialog({id:'2',title:'信息提示页面',page:'${ctx}/success.jsp',rang:true,iconTitle:false}).ShowDialog();
							dg.cancel();
						} else {
							var rowId = dg.curWin.$("#gridTable").getGridParam('selrow');
							dg.curWin.$("#gridTable").setRowData(rowId, dataRow, {color:"#FF0000"});
							new dg.curWin.$.dialog({id:'2',title:'信息提示页面',page:'${ctx}/success.jsp',rang:true,iconTitle:false}).ShowDialog();
							dg.cancel();
						}
					} else {
						dg.curWin.alert("修改操作失败！");
					}
				}
			});
		}
	</script>
</head>
<body>
<form id="ff" method="post">
<input type="hidden" id ="jgbh" name="jgbh" value="${jgbh}">
<input type="hidden" id ="id" name="gg_czyb.id" value="${gg_czyb.id}">
<table id="tt" title="系统功能信息" iconCls="icon-title">
	<tbody>
	<tr>
		<td>登录号：</td>
		<td><input id="dlh"  name="gg_czyb.dlh" style="width:200px;" value="${gg_czyb.dlh}"></td>
	</tr>
	<tr>
		<td>姓名：</td>
		<td><input id="mc" name="gg_czyb.mc" style="width:200px;" value="${gg_czyb.mc}"></td>
	</tr>
	</tbody>
</table>
</form>
</body>
</html>